package qeug.shsh.facde.resultext;

import kd.bos.openapi.common.custom.annotation.ApiModel;
import kd.bos.openapi.common.custom.annotation.ApiParam;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

@ApiModel
public class SupplierResulText implements Serializable {
    @ApiParam("操作失败数量")
    private int failCount;
    @ApiParam("操作成功数量")
    private int successCount;
    @ApiParam("返回结果")
    private List<ResultBean> result;

    public int getFailCount() {
        return failCount;
    }

    public void setFailCount(int failCount) {
        this.failCount = failCount;
    }

    public int getSuccessCount() {
        return successCount;
    }

    public void setSuccessCount(int successCount) {
        this.successCount = successCount;
    }

    public List<ResultBean> getResult() {
        return result;
    }

    public void setResult(List<ResultBean> result) {
        this.result = result;
    }

    @ApiModel
    public static class ResultBean implements Serializable {
        @ApiParam("错误校验提示内容详细")
        private List<String> errors;
        @ApiParam("返回的苍穹单据编号")
        private String number;

        public List<String> getErrors() {
            return errors;
        }
        public void setErrors(List<String> errors) {
            this.errors = errors;
        }

        public String getNumber() {
            return number;
        }
        public void setNumber(String number) {
            this.number = number;
        }
    }

    /**
     * 生成错误结果
     * @param index
     * @param errorMsg
     * @param number
     * @return
     */
    public static ResultBean failure(int index, String errorMsg, String number){
        List<String> errors = new ArrayList<>();
        errors.add(errorMsg);
        ResultBean resultBean = new ResultBean();
//        resultBean.setBillIndex(index);//传入参数data数组下标位
        resultBean.setErrors(errors);//错误信息
//        resultBean.setBillStatus(false);//单据处理状态
//        resultBean.setId("");//返回的苍穹单据id,唯一值
        resultBean.setNumber(number);//返回的苍穹单据编号
//        resultBean.setBillNo(number);//传入参数中业务系统单据唯一标识-单据编码
//        resultBean.setType(optionType);//操作类型：save、submit、audit
        return resultBean;
    }
}

